<template>
  <div class="page">
    <template v-if="result.evaluate&&result.evaluate.length">
    <div class="weui-cells" >
      <div class="weui-cell">
        <div class="weui-cell__bd">{{result.product&&result.product.spName}}</div>
      </div>
      <div class="weui-cell" v-for="item in result.evaluate ">
        <div class="weui-cell__bd group_content">
          <div class="weui-flex review">
            <img class="review_head" :src="item.merchantCard.image" mode="widthFix">
            <div class="weui-flex__item">
              <div class="review_user">
                <span>{{item.merchantCard.username||""}}</span>
                <div class="review_data">{{item.createTimeData}}</div>
              </div>
              <div class="review_star flex">
                综合评分
                <rate :number="item.skills"></rate>
              </div>
              <div class="review_con">
                {{item.content}}
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
    </template>
    <div class="weui-cell" v-else>
      <p  style="display: flex;justify-content: center;width:100%;">
        暂无评论
      </p>

    </div>
  </div>
</template>

<script>
import rate from '../../components/rate'
export default {
  data () {
    return {
      id:"",
      result:{},
      arr:[]
    }
  },
  onLoad(option){
    console.log(option)
    this.id=option.id;
  },
  components: {
    rate
  },
  onShow(){
    wx.setNavigationBarTitle({
      title: "全部评论"
    })
    this.getDetail()
  },
  methods: {
    changeDate(str){
      var time = new Date(str);
      return time.getFullYear()+"-"+time.getMonth()+1+"-"+time.getDate();
    },
    getDetail(){
      let that=this;
      console.log(123)
      this.$http.request({
        method: "post",
        url: "/v1.0/appletHome/appletProDetail",
        body: {
          "id":that.id,
          "status":"0"
        }
      }).then((data)=>{
        if(data.code==0){
          that.result=data.result;
          //  console.log(that.result.product.spName)
          if(that.result.evaluate.length){
            that.result.evaluate.forEach((a,i)=>{
              a.createTimeData=that.changeDate(a.createTime)
            })
          }
          that.arr=[]
          that.arr.push(that.result.product)
        }else{
          wx.showToast({
            title: `${data.message}`,
            icon: 'none',
            duration: 2000
          })
        }
      })
    }
  },

  created () {
    // let app = getApp()
  }
}
</script>

<style scoped>
.page{
  padding-bottom: 3.5em;
}
.review .review_head{
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  margin-right: 0.4em;
}
.review_user .review_data{
  font-size: 0.8em;
  float: right;
  color: #999;
}
.review_star{
  color: #999;
  font-size: 0.9em;
}
.review_star img{
  width: 1em;
}
.review_con{
  color: #666;
  font-size: 0.9em;
  padding: 0.3em 0;
}
</style>
